package com.burgeon.backend.EnterpriseWeChat.rest.action;
/**
 * 获取用户信息
 */


import com.burgeon.backend.EnterpriseWeChat.rest.base.RESTBase;
import org.json.JSONArray;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;

public class ActionRest extends RESTBase {

    private String ip;
    private String account;
    private String password;

    public ActionRest(String ip, String account, String password) {
        this.ip = ip;
        this.account = account;
        this.password = password;
    }

    public void getData(String actionName) throws Exception{
        String url = "http://"+ip+"/servlets/binserv/Rest";

        String str = RESULT(Data(actionName),url);

        String  code = new JSONArray(str).getJSONObject(0).getString("code");

        if (!"0".equals(code)) {
           throw new Exception(str);
        }

    }

    private MultiValueMap Data(String actionName) {
        HashMap params = new HashMap();

        params.put("webaction",actionName);
        params.put("id","0");

        return DATA("ExecuteWebAction", params,account,password);
    }

    public static void main(String[] args) {
        ActionRest g = new ActionRest("39.100.45.8:55321","nea@burgeon.com.cn","mgg55321");
        try {
            g.getData("");
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.err.println();

    }
}
